import os

from pyecharts.charts import Pie

from Basic.global_variables_path import *

data = [['通过的用例数', 1000], ['跳过的用例数', 100], ['异常的用例数', 100], ['失败的用例数', 100]]
date_time = time.strftime("%Y-%m-%d %H.%M.%S")
RESULT_PATH = os.path.join(global_project_path, f"results\\{date_time}--result.html")
pie = (
    Pie()
        .add('', data)
        # .render(RESULT_PATH)
)
pie.chart_id = 'pie'
from pyecharts.charts import Line
line_x = ['2022-09-23', '2022-09-24', '2022-09-25', '2022-09-26']
line_y1 = [1000, 499, 300, 889]
line_y2 = [700, 399, 250, 679]
line_y3 = [500, 299, 150, 569]
line_y4 = [99, 200, 100, 159]
line = (
    Line()
        .add_xaxis(line_x)
        .add_yaxis('通过的用例数',line_y1)
        .add_yaxis('跳过的用例数',line_y2)
        .add_yaxis('异常的用例数',line_y3)
        .add_yaxis('失败的用例数',line_y4)
        # .render(RESULT_PATH)
)
line.chart_id = 'line'
from pyecharts.charts import Page
page = (
    Page(layout=Page.DraggablePageLayout)
        .add(line, pie)
        .render(RESULT_PATH)
)

cfg_file = os.path.join(global_project_path, f"chart_config.json")
Page.save_resize_html(RESULT_PATH, cfg_file=cfg_file, dest=RESULT_PATH)

